import request from "@/utils/request";

export const getHostList = (params: any) => {
  return request<any, PageResult<Array<Host>>>({
    url: "/host",
    method: "get",
    params,
  });
};

export const getHostById = (id: number) => {
  return request({
    url: `/host/${id}`,
    method: "get",
  });
};

export const createHost = (data: any) => {
  return request({
    url: "/host",
    method: "post",
    data,
  });
};

export const updateHost = (id: number, data: any) => {
  return request({
    url: `/host/${id}`,
    method: "put",
    data,
  });
};

export const deleteHost = (id: number) => {
  return request({
    url: `/host/${id}`,
    method: "delete",
  });
};

export const certAuthentication = (id: number, data: any) => {
  return request({
    url: `/host/cert_authentication/${id}`,
    method: "put",
    data,
  });
};

export const tuneForKubernetes = (id: number) => {
  return request({
    url: `/host/tune_kubernetes/${id}`,
    method: "post",
  });
};

export interface Host {
  id?: number;
  hostname: string;
  publicIp: string;
  localIp: string;
  port: number;
  username: string;
  password: string;
  comment?: string;
}
